import timeago
from django import template
from django.utils.timezone import now
from two_comment.models import Comment,CommentReply
from two_comment.forms import CommentForm,CommentReplyForm

register = template.Library()



@register.simple_tag
def get_comment_list(entry):
    return entry.entry_comments.all()


@register.simple_tag
def get_reply_list(comment):
    return comment.comment_reply.all()




@register.simple_tag
def get_comment_form():
    return CommentForm()

@register.simple_tag
def get_reply_form():
    return CommentReplyForm()


@register.filter("timeago")
def timeago_filter(value):
    now_ = now()
    return timeago.format(value, now_, 'zh_CN')
